// pages/order/orderLogistics/orderLogistics.js
const common = require('../../../utils/util.js')
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        orderId: null,
        logisticInfo: null
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        this.setData({
            orderId: options.orderId
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        this.getLogisticInfo()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    getLogisticInfo: function() {
        wx.showLoading({
            title: '加载中'
        })
        const that = this
        let logisticInfo = this.data.logisticInfo
        let data = {
            order_id: this.data.orderId
        }
        common.post('Express/select_express', data).then(function(res) {
            wx.hideLoading()
            if (res.code == 204) {
                that.setData({
                    logisticInfo: res.error
                })
            } else {
                logisticInfo = res
                that.setData({
                    logisticInfo: logisticInfo
                })
            }
        }).catch(function(e) {})
    }
})